/* 
 * 创建日期 2011-7-19
 *
 * 成都天和软件公司
 * 电话：028-85425861 
 * 传真：028-85425861-8008 
 * 邮编：610041 
 * 地址：成都市武侯区航空路6号丰德万瑞中心B座1001 
 * 版权所有
 */
package  org.fantasy.question.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import  org.fantasy.cpp.web.controller.AbstractController;
import  org.fantasy.common.util.ParamMap;
import  org.fantasy.common.util.RequestUtil;
import  org.fantasy.question.pojo.StaffInfo;
import  org.fantasy.question.service.MaintainService;

/** 
 * <p>Title: MaintainController</p>  
 * <p>Description: </p>  
 * <p>Copyright: Copyright (c) 2011-7-19</p>  
 * @author 沈飞 
 * @version 1.0 
 */
@Controller
public class MaintainController extends AbstractController {
	private static final Log log = LogFactory.getLog(MaintainController.class);
	
	@Autowired
	private MaintainService maintainService;
	
	/**
	 * 员工信息页面初始化
	 * 
	 * @param pageId
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/question/page/staffEdit")
	public String queryStaffInfo(HttpServletRequest request, ModelMap model) throws Exception {
		String staffId = request.getParameter("id");
		log.info("页面初始化，页面ID:" + staffId);
		if (staffId != null) {
			StaffInfo bean = maintainService.getStaffInfo(Long.valueOf(staffId));
			model.addAttribute("bean", bean);
		} else {
			StaffInfo bean = new StaffInfo();
			model.addAttribute("bean", bean);
		}
		log.info("返回路径：/question/page/staffEdit");
		return "/question/page/staffEdit";
	}
	
	/**
	 * 保存员工信息
	 * @param request
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/question/page/staffSave")
	public String questionSave(HttpServletRequest request, ModelMap model) throws Exception {
		log.info("保存员工信息!");
		ParamMap<String,Object> params = RequestUtil.getParamMap(request);
		maintainService.saveStaffInfo(params);
		return result(model);
	}
}
